package ch02;

// 定义并打印变量
public class TestMain_232 {
    public static void main (String[] args){
        int n = 100; // 定义int类型变量n，并赋予初始值100
        System.out.println("n = " + n);// 打印该变量的值

        n = 200;// 变量n重新赋值为200
        System.out.println("n = " + n);

        int x = n ;// 变量x赋值为n（n的值为200，因此赋值后x的值也是200）
        System.out.println("x = " + x);

        x = x + 100;
        System.out.println("x = " + x);
        System.out.println("n = " + n);

        int i = 2147483647;  // 整型最大
        System.out.println("i = " + i);

        int i2 = -2147483648; // 整型最大
        System.out.println("i2 = " + i2);

        int i3 = 2_000_000_000; // 加下划线更容易识别
        System.out.println("i3 = " + i3);

        int i4 = 0xff0000; // 十六进制表示的16711680
        System.out.println("i4 = " + i4);

        int i5 = 0b1000000000; // 二进制表示的512
        System.out.println("i5 = " + i5);

        long n1 = 9000000000000000000L; // long型的结尾需要加L
        System.out.println("n1 = " + n1 );
        long n2 = 900; // 没有加L，此处900为int，但int类型可以赋值给long
        System.out.println("n2 = " + n2 );

        //int i6 = 900L; // 错误：不能把long型赋值给int

        float f1 = 3.14f;
        System.out.println("f1 = " + f1 );

        float f2 = 3.14e38f; // 科学计数法表示的3.14x10^38
        System.out.println("f2 = " + f2);
        //float f3 = 1.0; // 错误：不带f结尾的是double类型，不能赋值给float

        double d = 1.79e308;
        System.out.println("d = " + d);

        double d2 = -1.79e308;
        System.out.println("d2 = " + d2);

        double d3 = 4.9e-324; // 科学计数法表示的4.9x10^-324
        System.out.println("d3 = " + d3);

        boolean b1 = true;
        System.out.println("b1 = " + b1);

        boolean b2 = false;
        System.out.println("b2 = " + b2);

        boolean isGreater = 5 > 3; // 计算结果为true
        System.out.println( isGreater);

        int age = 12;
        boolean isAdult = age >= 18; // 计算结果为false
        System.out.println( isAdult);

        final double PI = 3.14;// PI是一个常量
        double r = 5.0;
        double area = PI * r * r;
        System.out.println("area =" + area);
       // PI = 300;
    }
}
